package com.company.Thread;

import jdk.nashorn.internal.ir.CallNode;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

/**
 * @ProjectName: 复习java
 * @Package: com.company.Thread
 * @ClassName: ThreadTest3
 * @Author: wym
 * @Date: 2020/8/5 12:00
 * @Version: 1.0
 * Array 问题
 */
public class ThreadTest3 {

    public static void main(String[] args) {
//        ArrayList<Object> test1 = new ArrayList<>();
////        test1.add("111");
////        test1.add("222");
////        test1.add("333");
////        Iterator<Object> objectIterator = test1.iterator();
////        while (objectIterator.hasNext()){
////            System.out.println(objectIterator.next());
////        }
        //变成2个集合
        List<Object> test1 = new CopyOnWriteArrayList<>();
        test1.add("111");
        test1.add("222");
        test1.add("333");
        Iterator<Object> objectIterator = test1.iterator();
        while (objectIterator.hasNext()){

            System.out.println(objectIterator.next());
            test1.add("4444");
        }

        System.out.println("---------------");
        Iterator<Object> objectIterator1= test1.iterator();
        while (objectIterator1.hasNext()){
            System.out.println(objectIterator1.next());
        }
    }

}
